package com.yang.studentsapp.ui.life;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.media.session.MediaControllerCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.yang.studentsapp.R;

/**
 * Created by ${Ян-Вэнь-Чао} on 2016/10/10.
 * 生活
 */
public class LifeFragment extends Fragment implements View.OnClickListener{
    RelativeLayout relativehua,relativeshu,relativejian;
    FragmentManager manager;
    LinearLayout linearfish,linearyiqiwan;
    RelativeLayout relativeLayout;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_life, container, false);
        linearfish = (LinearLayout) view.findViewById(R.id.life_fish);
        linearfish.setOnClickListener(this);
        manager = getActivity().getSupportFragmentManager();
        return view;
    }

//    @Override
//    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
//        super.onActivityCreated(savedInstanceState);
//        manager = getActivity().getSupportFragmentManager();
//
//        relativeLayout = (RelativeLayout) getActivity().findViewById(R.id.life_layout);
//        relativeLayout.setOnClickListener(new View.OnClickListener() {
//         FragmentTransaction transaction = manager.beginTransaction();
//            @Override
//            public void onClick(View v) {
//                switch (v.getId()) {
//                    case R.id.life_fish:
//                        transaction.replace(android.R.id.content, new FishFragment());
//                        transaction.addToBackStack(null);
//                        transaction.commit();
//                        break;
//                    case R.id.life_yiqiwan:
//                        transaction.replace(android.R.id.content, new PlayFragment());
//                        transaction.addToBackStack(null);
//                        break;
//                    case R.id.life_hua:
//                        transaction.replace(android.R.id.content, new TopicFragment());
//                        transaction.addToBackStack(null);
//                        break;
//                    case R.id.life_shu:
//                        transaction.replace(android.R.id.content, new TreeFragment());
//                        transaction.addToBackStack(null);
//                        break;
//                    case R.id.life_jian:
//                        transaction.replace(android.R.id.content, new JobFragment());
//                        transaction.addToBackStack(null);
//                        break;
//                }
//
//            }
//
//
//
//        });
//
//
//    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.life_fish:
                FragmentTransaction transaction = manager.beginTransaction();
                transaction.replace(android.R.id.content, new FishFragment());
                transaction.addToBackStack(null);
                transaction.commit();
                break;
        }
    }
}
